/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author 7P7
 */
@Entity
@Table(name = "Person", catalog = "NationalLevelPaperPresentation", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Person.findAll", query = "SELECT p FROM Person p"),
    @NamedQuery(name = "Person.findByPerID", query = "SELECT p FROM Person p WHERE p.perID = :perID"),
    @NamedQuery(name = "Person.findByFirstName", query = "SELECT p FROM Person p WHERE p.firstName = :firstName"),
    @NamedQuery(name = "Person.findByLastName", query = "SELECT p FROM Person p WHERE p.lastName = :lastName"),
    @NamedQuery(name = "Person.findByGender", query = "SELECT p FROM Person p WHERE p.gender = :gender"),
    @NamedQuery(name = "Person.findByDateOfBirth", query = "SELECT p FROM Person p WHERE p.dateOfBirth = :dateOfBirth"),
    @NamedQuery(name = "Person.findByAddress", query = "SELECT p FROM Person p WHERE p.address = :address"),
    @NamedQuery(name = "Person.findByPhone", query = "SELECT p FROM Person p WHERE p.phone = :phone"),
    @NamedQuery(name = "Person.findByCardNo", query = "SELECT p FROM Person p WHERE p.cardNo = :cardNo"),
    @NamedQuery(name = "Person.findByIsVisiable", query = "SELECT p FROM Person p WHERE p.isVisiable = :isVisiable")})
public class Person implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "PerID", nullable = false)
    private Integer perID;
    @Size(max = 64)
    @Column(name = "FirstName", length = 64)
    private String firstName;
    @Size(max = 64)
    @Column(name = "LastName", length = 64)
    private String lastName;
    @Column(name = "Gender")
    private Boolean gender;
    @Column(name = "DateOfBirth")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfBirth;
    @Size(max = 100)
    @Column(name = "Address", length = 100)
    private String address;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 16)
    @Column(name = "Phone", length = 16)
    private String phone;
    @Size(max = 50)
    @Column(name = "CardNo", length = 50)
    private String cardNo;
    @Column(name = "IsVisiable")
    private Boolean isVisiable;
    @OneToMany(mappedBy = "createPerID")
    private Collection<Event> eventCollection;
    @OneToMany(mappedBy = "perID")
    private Collection<Account> accountCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "person")
    private Student student;
    @OneToMany(mappedBy = "respondentID")
    private Collection<Feedback> feedbackCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "person")
    private Speaker speaker;
    @JoinColumn(name = "CardTypeID", referencedColumnName = "CardTypeID")
    @ManyToOne
    private CardType cardTypeID;

    public Person() {
    }

    public Person(Integer perID) {
        this.perID = perID;
    }

    public Integer getPerID() {
        return perID;
    }

    public void setPerID(Integer perID) {
        this.perID = perID;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Boolean getGender() {
        return gender;
    }

    public void setGender(Boolean gender) {
        this.gender = gender;
    }

    public Date getDateOfBirth() {
        return dateOfBirth;
    }

    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public Boolean getIsVisiable() {
        return isVisiable;
    }

    public void setIsVisiable(Boolean isVisiable) {
        this.isVisiable = isVisiable;
    }

    @XmlTransient
    public Collection<Event> getEventCollection() {
        return eventCollection;
    }

    public void setEventCollection(Collection<Event> eventCollection) {
        this.eventCollection = eventCollection;
    }

    @XmlTransient
    public Collection<Account> getAccountCollection() {
        return accountCollection;
    }

    public void setAccountCollection(Collection<Account> accountCollection) {
        this.accountCollection = accountCollection;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    @XmlTransient
    public Collection<Feedback> getFeedbackCollection() {
        return feedbackCollection;
    }

    public void setFeedbackCollection(Collection<Feedback> feedbackCollection) {
        this.feedbackCollection = feedbackCollection;
    }

    public Speaker getSpeaker() {
        return speaker;
    }

    public void setSpeaker(Speaker speaker) {
        this.speaker = speaker;
    }

    public CardType getCardTypeID() {
        return cardTypeID;
    }

    public void setCardTypeID(CardType cardTypeID) {
        this.cardTypeID = cardTypeID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (perID != null ? perID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Person)) {
            return false;
        }
        Person other = (Person) object;
        if ((this.perID == null && other.perID != null) || (this.perID != null && !this.perID.equals(other.perID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Person[ perID=" + perID + " ]";
    }
    
}
